package cn.schoolwow.util.domain.query.queryPackage;

import cn.schoolwow.util.module.query.queryPackage.domain.QueryPackageOption;

import java.util.function.Predicate;

public class QueryPackage {
    private QueryPackageOption queryPackageOption = new QueryPackageOption();

    /**
     * 创建查询包名对象
     * */
    public static QueryPackage newQuery(String packageName){
        QueryPackage queryPackage = new QueryPackage();
        queryPackage.queryPackageOption.packageName = packageName;
        return queryPackage;
    }

    /**查询指定类*/
    public QueryPackage addClassQuery(Class clazz){
        queryPackageOption.queryClassNameList.add(clazz.getName());
        return this;
    }

    /**待过滤类处理器*/
    public QueryPackage clazzRemovePredict(Predicate<Class> clazzRemovePredict){
        queryPackageOption.clazzRemovePredict = clazzRemovePredict;
        return this;
    }

    /**类名开始匹配*/
    public QueryPackage classNamePrefix(String classNamePrefix){
        queryPackageOption.classNamePrefix = classNamePrefix;
        return this;
    }

    /**类名结束匹配*/
    public QueryPackage classNameSuffix(String classNameSuffix){
        queryPackageOption.classNameSuffix = classNameSuffix;
        return this;
    }

    public QueryPackageResponse execute(){
        return new QueryPackageResponse(queryPackageOption);
    }
}
